#include<bits/stdc++.h>
#define fre(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
#define LL long long
#define db double
using namespace std;
int main(){
	fre(candy);
	int n,l,r;
	scanf("%d%d%d",&n,&l,&r);
	int a=l%n,b=r%n;
	if(r-l>=n||b<a)printf("%d",n-1);
	else printf("%d",b);
	return 0;
}

